package community.service.impl;

import community.dal.DatabaseSession;
import community.dao.IUserDao;
import community.dao.impl.UserDao;
import community.domain.User;
import community.exception.DatabaseException;
import community.service.IUserService;

public class UserService implements IUserService {
	IUserDao userdao = new UserDao();
	@Override
	public User Login(User u) throws DatabaseException {
		User user = null;
		
		try (DatabaseSession databaseSession = new DatabaseSession()) {
			user = userdao.Login(databaseSession, u);
		}
		return user;
	}

	@Override
	public User Register(User u) throws DatabaseException {
		User user = null;
		try (DatabaseSession databaseSession = new DatabaseSession()) {
			user = userdao.Register(databaseSession, u);
		}
		return user;
	}

	@Override
	public User getUserByuserid(String userid) throws DatabaseException {
		User user = null;
		try (DatabaseSession databaseSession = new DatabaseSession()) {
			user = userdao.getUserByuserid(databaseSession, userid);
		}
		return user;
	}

}
